package com.bestsoft.web.controller.flow;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestsoft.common.annotation.Log;
import com.bestsoft.common.core.controller.BaseController;
import com.bestsoft.common.core.domain.AjaxResult;
import com.bestsoft.common.enums.BusinessType;
import com.bestsoft.flow.domain.FlowGyslxLs;
import com.bestsoft.flow.service.IFlowGyslxLsService;
import com.bestsoft.common.utils.poi.ExcelUtil;
import com.bestsoft.common.core.page.TableDataInfo;

/**
 * 供应商流向(连锁)Controller
 * 
 * @author 崔健
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/flow/ls")
public class FlowGyslxLsController extends BaseController
{
    @Autowired
    private IFlowGyslxLsService flowGyslxLsService;

    /**
     * 查询供应商流向(连锁)列表
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowGyslxLs flowGyslxLs)
    {
        startPage();
        List<FlowGyslxLs> list = flowGyslxLsService.selectFlowGyslxLsList(flowGyslxLs);
        return getDataTable(list);
    }

    /**
     * 导出供应商流向(连锁)列表
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:export')")
    @Log(title = "供应商流向(连锁)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowGyslxLs flowGyslxLs)
    {
        List<FlowGyslxLs> list = flowGyslxLsService.selectFlowGyslxLsList(flowGyslxLs);
        ExcelUtil<FlowGyslxLs> util = new ExcelUtil<FlowGyslxLs>(FlowGyslxLs.class);
        util.exportExcel(response, list, "供应商流向(连锁)数据");
    }

    /**
     * 获取供应商流向(连锁)详细信息
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(flowGyslxLsService.selectFlowGyslxLsById(id));
    }

    /**
     * 新增供应商流向(连锁)
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:add')")
    @Log(title = "供应商流向(连锁)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowGyslxLs flowGyslxLs)
    {
        return toAjax(flowGyslxLsService.insertFlowGyslxLs(flowGyslxLs));
    }

    /**
     * 修改供应商流向(连锁)
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:edit')")
    @Log(title = "供应商流向(连锁)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowGyslxLs flowGyslxLs)
    {
        return toAjax(flowGyslxLsService.updateFlowGyslxLs(flowGyslxLs));
    }

    /**
     * 删除供应商流向(连锁)
     */
    @PreAuthorize("@ss.hasPermi('flow:ls:remove')")
    @Log(title = "供应商流向(连锁)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flowGyslxLsService.deleteFlowGyslxLsByIds(ids));
    }
}
